package com.qiangqiang.resoldhouse.mapper;

import com.qiangqiang.resoldhouse.entity.Area;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author : sky
 * @date : 2018/7/17
 * @description :
 */
@Mapper
public interface AreaMapper {

    @Select("select * from area where area_id = #{id}")
    public Area findAreaById(@Param("id") int id);

    @Select("select * from area where area_name=#{areaName}")
    public List<Area> findAreaByName(@Param("areaName") String areaName);

    @Select("select * from area")
    public List<Area> findAllAreas();


    @Insert("insert into area(area_id, update_time, create_time, area_name,city,province) values(#{area.areaId}, #{area.updateTime}, #{area.createTime}, #{area.areaName},#{area.city},#{area.province})")
    public int insertArea(@Param("area") Area area);

    @Delete("delete from area where area_id=#{id}")
    public int deleteAreaById(@Param("id") int id);

    @Update("update area set update_time=#{area.updateTime}, create_time=#{area.createTime}, area_name=#{area.areaName}," +
            "city=#{area.city}, province=#{area.province} where area_id=#{area.areaId}")
    public int updateArea(@Param("area") Area area);

}
